<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../css/app.css">
    <link rel="stylesheet" type="text/css" href="../css/index.css">
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="/pc/js/all.js"></script>
</head>
<body>
<!--
    制作者：九哥
    页面：发布岗位页面
    时间：2019-03-01
-->





<!----------发布岗位页面---------->
<div id="addJobPage"><!--此ID页面切换用-->
    <div id="addJobTitle">
        <b>发布岗位</b>
        <img src="../images/return.png" onclick="window.location.href='addType.html'">
    </div>
    <div id="addJobDetail">
        <p><b>选择部门</b></p>
        <ul id="addJobMenu">
        </ul>
        <ul id="addJobMenu2">
        </ul>
        <p><button id="addJob2">下一步</button></p>
    </div>
</div>
<!----------发布岗位页面---------->





<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->
</body>
<script type="text/javascript" src="../js/indexPageChange.js"></script>
<script type="text/javascript" src="../js/index.js"></script>
<script type="text/javascript" src="../js/alertMsg.js"></script>
<script type="text/javascript" src="../js/cache.js"></script>
<script type="text/javascript">
    var w = {};
    (function(){
        getJobsList();
    })();
    //获取岗位列表
    function getJobsList(){
        $.getJSON('/api/home/release/job_list', function(result) {
            if (result.code === 200) {
                data = result.data;
                w.position = data;
                var add = "";
                var add2 = "";
                for (var i = 0; i < data.length; i++) {
                    // console.log(typeof data[i]);
                    var position = data[i];
                    if (typeof position == 'object') {
                        add = add + '<li class="job" onclick="addJobF(this)" value = '+ i +'>' + position.position.name + "</li>";
                        // add2 = add2 + "<li>  </li>";
                    }
                }
                $("#addJobMenu").html(add)
                // $("#addJobMenu2").html(add2)
            }else{
                alertMsg("网络不稳定，请稍等。。。");
            }
        })
    }
    function addJobF(o)
    {
        var ad = w.position[o.value].position.job;
        var ad_string = '';
        for (var i = 0; i < ad.length; i++){
            var s = ad[i].name;
            ad_string = ad_string + "<li class='job2' value="+ ad[i].id +" onClick='setJobId(this)'>"+ s +"</li>"
        }
        $("#addJobMenu2").html(ad_string);
        $(".job").css({background:'#eeeeee'});
        o.setAttribute('style', 'background: #ffffff');
    }
    function setJobId(o)
    {
        $(".job2").css({background:'#ffffff'});
        o.setAttribute('style', 'background: #eeeeee');
        localStorage.setItem('addjob_job_id', o.value);
        localStorage.setItem('addjob_job_name', o.textContent);
        w.job_id = true;
    }
    $("#addJob2").click(function(){
        if (!w.job_id) {
            alertMsg('请选择一个职位');
            return;
        }
        window.location.href = "job/jobForm.html";
    })
</script>
</html>